package jmu.tools.file.sync.util ;


import java.io.File ;

public class SyncResult
{
    // results
    private long fileTotal = 0 ;
    private long fileProcessed = 0 ;
    private long fileSizeTotal = 0 ;
    private long fileSizeProcessed = 0 ;
    private long fileSuccess = 0 ;
    private long fileSizeSuccess = 0 ;
    private long fileFailed = 0 ;
    private long fileSizeFailed = 0 ;

    public synchronized void download ( final File file )
    {
        fileSuccess++ ;
        fileSizeSuccess = fileSizeSuccess + file.length () ;
    }

    public synchronized void fail ( final File source )
    {
        fileFailed++ ;
        fileSizeSuccess = fileSizeSuccess + source.length () ;
    }

    public void print ()
    {
        System.out.println ( "Summary:" ) ;
        System.out.println ( "- Scanned:" ) ;
        System.out.println ( "\tfiles\t" + fileTotal ) ;
        System.out.println ( "\tsize\t" + fileSizeTotal + " bytes" ) ;
        System.out.println () ;
        System.out.println ( "- Synchronized:" ) ;
        System.out.println ( "\tfiles\t" + fileProcessed ) ;
        System.out.println ( "\tsize\t" + fileSizeProcessed + " bytes" ) ;
        System.out.println () ;
        System.out.println ( "- Downloaded:" ) ;
        System.out.println ( "\tfiles\t" + fileSuccess ) ;
        System.out.println ( "\tsize\t" + fileSizeSuccess + " bytes" ) ;
        System.out.println () ;
        System.out.println ( "- Failed:" ) ;
        System.out.println ( "\tfiles\t" + fileFailed ) ;
        System.out.println ( "\tsize\t" + fileSizeFailed + " bytes" ) ;
    }

    public synchronized void scan ( final File file )
    {
        fileTotal++ ;
        fileSizeTotal = fileSizeTotal + file.length () ;
    }

    public synchronized void synchronize ( final File file )
    {
        fileProcessed++ ;
        fileSizeProcessed = fileSizeProcessed + file.length () ;
    }
}
